<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()	+ path + "/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<%@include file="../include/contentheader.jsp"%>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/dtree.css" />
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="dwr/engine.js"></script>
	<script type="text/javascript" src="dwr/util.js"></script>
	<script type="text/javascript" src="dwr/interface/categoryManager.js"></script>
	<script type="text/javascript">
		function doSelect(did,dname){
			if(did != undefined && dname != undefined){
				window.returnValue = did+','+dname;
			}else{
				window.returnValue = '';
			}
		}
		function doOk(){
			if(window.returnValue == undefined){
				window.returnValue = '';
			}
			window.close();
		}
		function doCancel(){
			window.returnValue = '';
			window.close();
		}
	</script>
	</head>
	<body onload="buildTree();" style="padding-top:5px;">
		<div>
			<div class="headerTitle">请选择资产类别</div>
			<div><input type="button" onclick="doOk();" value="确定" /><input type="button" onclick="doCancel();" value="取消" /></div>
			<div id="myTree" style="width:100%;height:400px;overflow-y:auto;color:#333333;border:1px solid #C0C0C0;border-right:0px;border-bottom:0px;">
			<script type="text/javascript">	
				dtree = new dTree('dtree');
				dtree.clearCookie();
				function buildTree(){
					categoryManager.findAllCategory(function(category) {
						dtree.add(0, -1, '资产类别');
						for(var i=0; i<category.length; i++){
							var size = category[i].catid.length;
							var name = category[i].catname;
							if(size == 3){
								dtree.add(category[i].catid,0,name,"javascript:doSelect(\'"+category[i].catid+"\',\'"+name+"\')");
							}else if(size == 6){
								dtree.add(category[i].catid,category[i].catid.substr(0,3),name,"javascript:doSelect(\'"+category[i].catid+"\',\'"+name+"\')");
							}else if(size == 10){
								dtree.add(category[i].catid,category[i].catid.substr(0,6),name,"javascript:doSelect(\'"+category[i].catid+"\',\'"+name+"\')");
							}
						}
						showBuildTree(dtree.toString());
					});
				}
				function showBuildTree(treeStr) {
					document.getElementById("myTree").innerHTML = treeStr;
				}
			</script>
			</div>
		</div>
	</body>
</html>